clear all
set more off
version 14.0

/*=================================================================
	PART A: COCA DATA
=================================================================*/

use "./drugs-data.dta", clear

cap drop year2
gen year2 = year + 0.5

two (bar coca year, barwidth(.5))(bar eradicate year2, barwidth(.5))



/*=================================================================
	PART B: EXPERIMENT DATA 
=================================================================*/

use "./eradication-note.dta", clear

global treat T_afro T_protestas T_afro_protestas
global indiv female afro indigen 
global educa edu2 edu3 edu4 edu5
global polit ideo2 ideo3 ideo4 ideo5 ideo6 ideo7 
global check timeq check1 check2 check3 check4
global dptos i.dptocode
global cocas coca5y 
global ctrls $indiv $polit $educa 


/*=================================================================
	PART C: TABLES AND FIGURES
=================================================================*/

** TABLE (1) DESCRIPTIVE STATISTICS
sum forced_1 forced_2 forced_3 $treat 	///
	$indiv ideo1 $polit edu1 $educa $cocas $check 


** TABLE (3) MARGINAL EFFECTS 
* MULTINOMIAL LOGIT - MAIN MODEL
* never eradicate
qui mlogit forced $treat $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(0)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* eradicate conditionally
qui mlogit forced $treat $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(1)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* always eradicate
qui mlogit forced $treat $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(2)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas

* MULTINOMIAL LOGIT - MAIN MODEL
* never eradicate
qui mlogit forced $treat $ctrls $cocas $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(0)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* eradicate conditionally
qui mlogit forced $treat $ctrls $cocas $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(1)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* always eradicate
qui mlogit forced $treat $ctrls $cocas $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(2)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas

* never eradicate
qui mlogit forced $treat $ctrls $dptos $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(0)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* eradicate conditionally
qui mlogit forced $treat $ctrls $dptos $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(1)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* always eradicate
qui mlogit forced $treat $ctrls $dptos $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(2)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas


** FIGURE (2)
*plot the values from table 3


/*=================================================================
	PART D: APPENDIX 
=================================================================*/

** TABLE (A1) DISTRIBUTION OF TREATMENTS
tab T_protestas T_afro

** TABLE (A2) BALANCE TEST 
sum $indiv ideo1 $polit edu1 $educa if T_afro==0 & T_protestas==0
sum $indiv ideo1 $polit edu1 $educa if T_afro==1 & T_protestas==0
sum $indiv ideo1 $polit edu1 $educa if T_afro==0 & T_protestas==1
sum $indiv ideo1 $polit edu1 $educa if T_afro==1 & T_protestas==1

** TABLE (A3) MARGINAL EFFECTS MAIN MODEL
* MULTINOMIAL LOGIT - MAIN MODEL
* never eradicate
qui mlogit forced $treat $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(0)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* eradicate conditionally
qui mlogit forced $treat $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(1)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* always eradicate
qui mlogit forced $treat $check if sample==1, robust
margins , dydx($treat ) predict(pr outcome(2)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas

* MULTINOMIAL LOGIT - MAIN MODEL
* never eradicate
qui mlogit forced $treat $ctrls $cocas $check if sample==1, robust
margins , dydx($treat $ctrls $cocas ) predict(pr outcome(0)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* eradicate conditionally
qui mlogit forced $treat $ctrls $cocas $check if sample==1, robust
margins , dydx($treat $ctrls $cocas ) predict(pr outcome(1)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* always eradicate
qui mlogit forced $treat $ctrls $cocas $check if sample==1, robust
margins , dydx($treat $ctrls $cocas ) predict(pr outcome(2)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas

* never eradicate
qui mlogit forced $treat $ctrls $dptos $check if sample==1, robust
margins , dydx($treat $ctrls $dptos ) predict(pr outcome(0)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* eradicate conditionally
qui mlogit forced $treat $ctrls $dptos $check if sample==1, robust
margins , dydx($treat $ctrls $dptos ) predict(pr outcome(1)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas
* always eradicate
qui mlogit forced $treat $ctrls $dptos $check if sample==1, robust
margins , dydx($treat $ctrls $dptos ) predict(pr outcome(2)) post atmeans
lincom T_protestas+T_afro+T_afro_protestas


** TABLE (A4) ROBUSTNESS FOR THE MAIN MODEL
qui mlogit forced $treat $ctrls $dptos , robust
margins , dydx($treat $ctrls ) predict(pr outcome(2)) post atmeans
qui mlogit forced $treat $ctrls $dptos , robust
margins , dydx($treat $ctrls ) predict(pr outcome(1)) post atmeans
qui mlogit forced $treat $ctrls $dptos , robust
margins , dydx($treat $ctrls ) predict(pr outcome(0)) post atmeans

qui mlogit forced T_afro T_protestas $ctrls $dptos , robust
margins , dydx(T_afro T_protestas $ctrls ) predict(pr outcome(2)) post atmeans
qui mlogit forced T_afro T_protestas $ctrls $dptos , robust
margins , dydx(T_afro T_protestas $ctrls ) predict(pr outcome(1)) post atmeans
qui mlogit forced T_afro T_protestas $ctrls $dptos , robust
margins , dydx(T_afro T_protestas $ctrls ) predict(pr outcome(0)) post atmeans

qui mlogit forced $treat $ctrls i.income i.age $dptos , robust
margins , dydx($treat $ctrls ) predict(pr outcome(2)) post atmeans
qui mlogit forced $treat $ctrls i.income i.age $dptos , robust
margins , dydx($treat $ctrls ) predict(pr outcome(1)) post atmeans
qui mlogit forced $treat $ctrls i.income i.age $dptos , robust
qui margins , dydx($treat $ctrls ) predict(pr outcome(0)) post atmeans

  
** TABLE (A5) DESCRIPTIVE STATISTICS
cap drop _i _a
qui tab age , gen(_a)
qui tab income , gen(_i)
sum _a1 _a2 _a3 _a4 _a5 _a6 _i1 _i2 _i3 _i4 _i5 _i6 _i7 _i8 _i9 _i10


** TABLE (A6) ROBUSTNESS TO COCA EXPOSURE
foreach x in coca5y coca10y coca22 coca23 {
	
	* MULTINOMIAL LOGIT
	* never eradicate
	qui mlogit forced $treat $ctrls `x' $check if sample==1, robust
	margins , dydx($treat `x' ) predict(pr outcome(0)) post atmeans
	lincom T_protestas+T_afro+T_afro_protestas
	* eradicate conditionally
	qui mlogit forced $treat $ctrls `x' $check if sample==1, robust
	margins , dydx($treat `x' ) predict(pr outcome(1)) post atmeans
	lincom T_protestas+T_afro+T_afro_protestas
	* always eradicate
	qui mlogit forced $treat $ctrls `x' $check if sample==1, robust
	margins , dydx($treat `x' ) predict(pr outcome(2)) post atmeans
	lincom T_protestas+T_afro+T_afro_protestas
}


** TABLE (A7) ROBUSTNESS TO FUMIGATION EXPOSURE
foreach x in spray5y spray10y spray14 spray15 {
	
	* MULTINOMIAL LOGIT
	* never eradicate
	qui mlogit forced $treat $ctrls `x' $check if sample==1, robust
	margins , dydx($treat `x' ) predict(pr outcome(0)) post atmeans
	lincom T_protestas+T_afro+T_afro_protestas
	* eradicate conditionally
	qui mlogit forced $treat $ctrls `x' $check if sample==1, robust
	margins , dydx($treat `x' ) predict(pr outcome(1)) post atmeans
	lincom T_protestas+T_afro+T_afro_protestas
	* always eradicate
	qui mlogit forced $treat $ctrls `x' $check if sample==1, robust
	margins , dydx($treat `x' ) predict(pr outcome(2)) post atmeans
	lincom T_protestas+T_afro+T_afro_protestas
}



** TABLE (A8) MARGINAL EFFECTS USING ALTERNATIVE TREATMENTS
qui mlogit forced T2 T3 T4 $dptos , robust
margins , dydx(T2 T3 T4 ) predict(pr outcome(2)) post atmeans
qui mlogit forced T2 T3 T4 $dptos , robust
margins , dydx(T2 T3 T4 ) predict(pr outcome(1)) post atmeans
qui mlogit forced T2 T3 T4 $dptos , robust
margins , dydx(T2 T3 T4 ) predict(pr outcome(0)) post atmeans

qui mlogit forced T2 T3 T4 $ctrls $dptos , robust
margins , dydx(T2 T3 T4 $ctrls ) predict(pr outcome(2)) post atmeans
qui mlogit forced T2 T3 T4 $ctrls $dptos , robust
margins , dydx(T2 T3 T4 $ctrls ) predict(pr outcome(1)) post atmeans
qui mlogit forced T2 T3 T4 $ctrls $dptos , robust
margins , dydx(T2 T3 T4 $ctrls ) predict(pr outcome(0)) post atmeans


** TABLE (A9) BALANCE TEST IN A 2X2 DESIGN
sum $indiv ideo1 $polit edu1 $educa if T1==0
sum $indiv ideo1 $polit edu1 $educa if T2==1
sum $indiv ideo1 $polit edu1 $educa if T3==1
sum $indiv ideo1 $polit edu1 $educa if T4==1


** TABLE (A10) DISTRIBUTION FORCED VOLUNTARY
tab forced voluntary


** FIGURE (A1) SELF-REPORT IDEOLOGY AND VOTE CHOICE
two (hist ideology , discrete freq col(gs10) barwidth(.9))	///
	(hist ideology if Petro==1, freq discrete col(red*.8) barwidth(.9)) 	///
	, graphregion(color(white)) ytit("Number of respondents") 	///
	xtit("Self-report ideology") xlabel(1 "Far-left" 2 "Left" 3 "Center-left" 4 "Center" 5 "Center-right" 6 "Right" 7 "Far-right", labsize(small)) 	///
	legend(on col(1) ring(0) pos(1) order( 1 "Hernandez" 2 "Petro"))


** FIGURE (A2) PREDICTED PROBABILITY BY RESPONDENTS' IDEOLOGY AND RACE TREATMENT
qui mlogit forced i.T_afro i.T_protestas i.T_afro_protestas $ctrls $cocas $check , robust level(90)
margins T_afro , by(ideology ) post atmeans noatlegend level(90)
marginsplot, by(T_afro )


** FIGURE (A3) PREDICTED PROBABILITY BY RESPONDENTS' IDEOLOGY AND PROTEST TREATMENT
qui mlogit forced i.T_afro i.T_protestas i.T_afro_protestas $ctrls $cocas $check , robust level(90)
margins T_protestas , by(ideology ) post atmeans noatlegend level(90)
marginsplot, by(T_protestas )


/*=================================================================
	END OF DO-FILE
=================================================================*/
